home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 19.zip / BS1 part 19 / Enigme a Oxford BS1.adf / edueni.c < prev    next >
C/C++ Source or Header  |  1988-07-27  |  31KB  |  1,288 lines

  1. #define FORWARD extern
  2. #define noire  0
  3. #define rouge  1
  4. #define verte  2  
  5. #define jaune  3  
  6. #define bleue  4  
  7. #define rose  5  
  8. #define cyane  6  
  9. #define blanc  7  
  10.  
  11. #define fh  11    
  12. #define fb  10    
  13. #define fd   9   
  14. #define fg   8    
  15. #define del  127    
  16. #define clr   16   
  17. #define esc   27 
  18. #define spc 32  
  19.  
  20. #define eCLIC 0x01
  21. #define eCLAV 0x02
  22.  
  23.  
  24.  
  25. #undef NULL
  26. #define NULL ((void *)0)
  27.  
  28. #define MEMOIRE 64000L
  29. #define ALLOUER(a,b)   ((a *)AllocMem(sizeof(a),b))
  30. #define CREER(v,t,m)   (v=(struct t *)AllocMem(sizeof(struct t),m))
  31. #define LIBERER(x,t)    FreeMem((char *)x,sizeof(struct t))
  32. #define NOISENUMBER 1  
  33.            
  34. #define abs(x)         (x>=0)?x:-x
  35. #define ecrtab(y,x)  (*(tableau+x)=y) 
  36. #define litab(x) ((int)*(tableau+x))
  37.  
  38.  
  39. typedef struct Chaine
  40.    {int len; 
  41.    char c[256]; } CHAINE;
  42. FORWARD char upcase();
  43. extern struct Library *OpenLibrary();
  44. extern void CloseLibrary();
  45. extern struct Window *OpenWindow();
  46. extern void CloseWindow();
  47. extern struct Screen *OpenScreen();
  48. extern void CloseScreen();
  49. extern void ShowTitle();
  50. extern void SetPointer();
  51. extern void ClearPointer();
  52.  
  53. extern long OpenWorkbench();
  54. extern long CloseWorkbench();
  55. extern void ActivateWindow();
  56.  
  57. extern void ModifyIDCMP();
  58. extern struct Message *GetMsg();
  59. extern void ReplyMsg();
  60. extern void Delay();
  61. extern void *AllocMem();
  62. extern void FreeMem();
  63. extern void *AllocRaster();
  64. extern void FreeRaster();
  65. extern void InitBitMap();
  66. extern void SetRGB4();
  67. extern void SetDrMd();
  68. extern void SetAPen();
  69. extern void SetBPen();
  70. extern void Draw();
  71. extern void Move();
  72. extern long BltBlitMap();
  73. extern short Examine();
  74. extern struct FileLock *Lock();
  75. extern void Unlock();
  76. extern struct FileHandle *Open();
  77. extern long Read();
  78. extern void Close();
  79.  
  80.   UBYTE pointeurkm[128]=
  81. { 0x7e, 0x60,  /*  ~ `  */  0x31, 0x26,  /*  1 &  */  0x32, 0x16,  /*  2 e' */ 
  82.  0x33, 0x22,   /*  3 "  */  0x34, 0x27,  /*  4 '  */  0x35, 0x28,  /*  5 (  */
  83.   0x36, 0xa4,  /*  6 par*/  0x37, 0x17,  /*  7 e` */  0x38, 0x21,  /*  8 !  */ 
  84.  0x39, 0x63,   /*  9 c, */  0x30, 0x18,  /*  0 a` */  0xa1, 0x29,  /* no )  */
  85.   0x5f, 0x2d,  /*  _ -  */  0x7c, 0x5c,  /*  | \  */  0x00, 0x00,  /*       */ 
  86.  0x30, 0x30,   /*  0 0  */  0x41, 0x61,  /*  A a  */  0x5a, 0x7a,  /*  Z z  */
  87.   0x45, 0x65,  /*  E e  */  0x52, 0x72,  /*  R r  */  0x54, 0x74,  /*  T t  */ 
  88.  0x59, 0x79,   /*  Y y  */  0x55, 0x75,  /*  U u  */  0x49, 0x69,  /*  I i  */
  89.   0x4f, 0x6f,  /*  O o  */  0x50, 0x70,  /*  P p  */  0xac, 0x5e,  /* .. ^  */
  90.   0x2a, 0x24,  /*  * $  */  0x00, 0x00,  /*       */  0x31, 0x31,  /*  1 1  */
  91.   0x32, 0x32,  /*  2 2  */  0x33, 0x33,  /*  3 3  */  0x51, 0x71,  /*  Q q  */
  92.   0x53, 0x73,  /*  S s  */  0x44, 0x64,  /*  D d  */  0x46, 0x66,  /*  F f  */
  93.   0x47, 0x67,  /*  G g  */  0x48, 0x68,  /*  H h  */  0x4a, 0x6a,  /*  J j  */
  94.   0x4b, 0x6b,  /*  K k  */  0x4c, 0x6c,  /*  L l  */  0x4d, 0x6d,  /*  M m  */
  95.   0x25, 0x11,  /*  % u` */  0x24, 0x24,  /* livre */  0x24, 0x24,  /*  livre*/
  96.   0x34, 0x34,  /*  4 4  */  0x35, 0x35,  /*  5 5  */  0x36, 0x36,  /*  6 6  */
  97.   0x3e, 0x3c,  /*  > <  */  0x57, 0x77,  /*  W w  */  0x58, 0x78,  /*  X x  */
  98.   0x43, 0x63,  /*  C c  */  0x56, 0x76,  /*  V v  */  0x42, 0x62,  /*  B b  */
  99.   0x4e, 0x6e,  /*  N n  */  0x3f, 0x2c,  /*  ? ,  */  0x2e, 0x3b,  /*  . ;  */
  100.   0x2f, 0x3a,  /*  / :  */  0x2b, 0x3d,  /*  + =  */  0x00, 0x00,  /*       */
  101.   0x2e, 0x2e,  /*  . .  */  0x37, 0x37,  /*  7 7  */  0x38, 0x38,  /*  8 8  */
  102.   0x39, 0x39   /*  9 9  */
  103. };
  104.  
  105. #define HAUTECRAN 20
  106.   struct GfxBase  *GfxBase=NULL;
  107.   struct IntuitionBase *IntuitionBase=NULL;
  108.   struct Library *DiskfontBase=NULL;
  109.   UBYTE *lettres;
  110.      struct NewScreen newScreen={ 0,HAUTECRAN,320,200,4,0,0,NULL,CUSTOMSCREEN,
  111.                                     NULL,NULL,NULL,NULL};
  112.      struct NewWindow newWindow={ 0,0,320,200,0,0,RAWKEY,
  113.                                    BORDERLESS|NOCAREREFRESH|RMBTRAP,NULL,NULL,
  114.                                NULL,NULL,NULL,320,200,320,200,CUSTOMSCREEN};
  115.      struct Screen *screen = NULL;
  116.      struct Window *window = NULL;
  117.  
  118.      struct Window *amigadoswin = NULL;
  119.  
  120.  
  121.      struct RastPort *rastPort = NULL;
  122.      struct ViewPort *viewPort = NULL;
  123.      struct BitMap *bitMap = NULL;
  124.      struct IntuiMessage *intuiMessage = NULL;
  125.      UWORD *sourisOff;   /*[]={0,0,0,0,0,0};*/
  126.      int c = 0;
  127.  
  128.     struct sFen { int x,y,l,h; struct BitMap *bit; };
  129.      struct sFen fen[10];
  130.  
  131. CHAINE vide;
  132.  
  133.   int  a,i,j,k,touche,code,note;
  134.   int  mousex,mousey,amousex,amousey,deltax,deltay;
  135.   UWORD longueur;
  136.  
  137.   UBYTE *tableau ;
  138.   int   variable[256] ;
  139.   LONG tabadr[11];
  140.   int  pttab;
  141.   char  nomfich[25] ;
  142.   char filename[25];
  143.  
  144.   LONG adr_retour=0L;
  145.   LONG adresse=0L;
  146.   LONG pointe,pointer,n,memoire,kar;
  147.   int  hauteur,posx,posy, typecr,c_fond,c_forme,c_over;
  148.   CHAINE buflig,bufsais,reponse;
  149.   BOOL cadre, souli, c_deux, musicok,sortie;
  150.   int  numfen,nbfen,ptrfen;
  151.   int max,compteur,curse;
  152.   char ch;
  153.   int clicx,clicy;
  154.   int evenmt;
  155.  
  156.   int  maxpageLivre;
  157.   int  a_pageLivre[11] ;
  158.   int  pageLivre;
  159.   int a_base,  zone,px,py,lg,c1,memo;
  160.   LONG a_champ;
  161.   CHAINE phrase[21]; 
  162.   int  soluti[10][10],repons[10][10]; 
  163.  
  164.   BYTE tableaubing[8]={120,60,0,-60,-120,-60,0,60};
  165.   BYTE *tablebing;
  166.   BYTE *NameNoise;
  167. void show_mouse()
  168. {
  169. ClearPointer(window);
  170. }
  171.  
  172. void hide_mouse()
  173. {
  174. SetPointer(window,sourisOff,1,16,0,0);
  175. }
  176.  
  177. /******************** afiimbr asm ****************************/
  178.  
  179.  
  180. #asm
  181.        cseg
  182.            public _afiimbr
  183. _afiimbr:
  184.            movem.l d0-d7/a0-a4,-(sp)
  185.  
  186.            clr.l   d0
  187.            clr.l   d1
  188.            clr.l   d2
  189.            clr.l   d3
  190.            clr.l   d4
  191.            clr.l   d5
  192.            clr.l   d6
  193.            clr.l   d7
  194.            jmp     debut
  195.  
  196. suite      move.b  (a0),d6         
  197.            and.l   #$000000f0,d6  
  198.            lsl.w   #8,d6          ;couleurs
  199.            lsl.l   #1,d6
  200.            swap    d6
  201.            lsl.w   #7,d6
  202.            swap    d6
  203.            lsl.l   #1,d6
  204.            lsr.w   #7,d6
  205.            lsr.b   #7,d6
  206.            move.b  (a0)+,d4       
  207.            btst    #3,d4     
  208.            beq     nblong
  209. nbcourt    and.b   #$7,d4  
  210.            addq.b  #1,d4         ;nombre de points
  211.            rts
  212.  
  213. nblong     and.b   #$7,d4
  214.            lsl.w   #8,d4
  215.            move.b  (a0)+,d4   
  216.            addq.w  #1,d4         ;nombre de points
  217.            rts
  218.  
  219. debut      move.l  72(sp),a0    ; a0 = adrimage
  220.            move.l  76(sp),a1    ; a1 = adrplan
  221.            move.l  4(a1),a2     ; a2 = plan1
  222.            move.l  8(a1),a3     ; a3 = plan2
  223.            move.l  12(a1),a4    ; a4 = plan3
  224.            move.l  (a1),a1      ; a1 = plan0
  225.  
  226.            move.l  68(sp),d1    ; d1 = h
  227.            subq.l  #1,d1        ; d1 = h-1
  228.            move.l  64(sp),d2    ; d2 = l
  229.            subq.l  #1,d2        ; d2 = l-1
  230.            move.l  60(sp),d3    ; d3 = y
  231.            mulu    #40,d3       ; d3 = y*40
  232.            add.l   56(sp),d3    ; d3 = y*40+x
  233.  
  234. lignes     move.l  d3,-(sp)     ; position (debut de ligne) dans le plan
  235.            move.l  d2,d7        ; initialise d7 avec d2 = largeur
  236.  
  237. colonnes   move.l  #7,d0        ;compteur des bits de l'octet du plan
  238.            clr.l   d5           ;octet a ecrire dans un plan
  239.  
  240. bitsuivant cmp.w   #0,d4
  241.            bne     plans
  242.            bsr     suite
  243.  
  244. plans      lsl.l   #1,d5        ;
  245.            add.l   d6,d5
  246.            subq.w  #1,d4
  247.            dbra    d0,bitsuivant 
  248.            move.b  d5,0(a1,d3.l)
  249.            lsr.w   #8,d5
  250.            move.b  d5,0(a2,d3.l)
  251.            swap    d5
  252.            move.b  d5,0(a3,d3.l)
  253.            lsr.w   #8,d5
  254.            move.b  d5,0(a4,d3.l)
  255.            addq.l  #1,d3
  256.            dbra    d7,colonnes
  257.            move.l  (sp)+,d3
  258.            add.l   #40,d3
  259.            dbra    d1,lignes
  260.            movem.l (sp)+,d0-d7/a0-a4
  261.            rts
  262. #endasm
  263.  
  264.  
  265.  
  266. #asm
  267.  
  268. ;sons(table,periode,longueur)
  269.  
  270.    cseg
  271.    public _sons
  272.    public _silence
  273.  
  274. _sons:
  275.   
  276. ctlw:   equ $dff096
  277. c0thi:  equ $dff0a0
  278. c0tlo:  equ c0thi+2
  279. c0tl:   equ c0thi+4
  280. c0per:  equ c0thi+6
  281. c0vol:  equ c0thi+8
  282. c1thi:  equ $dff0b0
  283. c1tlo:  equ c1thi+2
  284. c1tl:   equ c1thi+4
  285. c1per:  equ c1thi+6
  286. c1vol:  equ c1thi+8
  287. intreqw: equ $dff09c
  288. intreqr: equ $dff01e
  289.  
  290. run:
  291.  
  292. ;PILE
  293. ;sp     adr retour
  294. ;sp+4   adr table
  295. ;sp+8   periode
  296. ;sp+12  longueur
  297.  
  298.  
  299.     move.l  4(sp),c0thi
  300.     move.w  14(sp),c0tl
  301.     move.w  10(sp),c0per
  302.     move    #$40,c0vol
  303.     move.l  4(sp),c1thi
  304.     move.w  14(sp),c1tl
  305.     move.w  10(sp),c1per
  306.     move    #$40,c1vol
  307.  
  308.     move.w  #$8203,ctlw
  309.     rts
  310.  
  311.     
  312. _silence:
  313.  
  314.     movem.l d0,-(sp)
  315.     clr.l   d0
  316.  
  317.     move.w  #$0780,intreqw
  318.  
  319. waitstop:
  320.     move.w  intreqr,d0
  321.     and.w   #$0180,d0
  322.     beq.s   waitstop
  323.  
  324.     move.w  #3,ctlw
  325.  
  326.     movem.l (sp)+,d0
  327.     rts
  328.  
  329. #endasm
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336. /*********************** caracteres *********************/
  337. #asm
  338.  
  339. ; routine d'affichage de caractere 
  340. ; void afi040(ascii,x,y,fond,forme,lettres,base)
  341. ; int       ascii ;
  342. ; int       x,y,fond,forme;
  343. ; UBYTE     *lettres ;
  344. ; PLANEPTR  *base: &(bitMap->Planes[0])
  345.  
  346. ; ETAT DE LA PILE APRES MOVEM.
  347.  
  348. ; sp+0    a4   
  349. ; sp+4    a3
  350. ; sp+8    a2
  351. ; sp+12   a1
  352. ; sp+16   a0
  353. ; sp+20   d7
  354. ; sp+24   d6
  355. ; sp+28   d5   
  356. ; sp+32   d4
  357. ; sp+36   d3     
  358. ; sp+40   d2
  359. ; sp+44   d1
  360. ; sp+48   d0
  361. ; sp+52   adr retour
  362. ; sp+56   ascii
  363. ; sp+60   x
  364. ; sp+64   y
  365. ; sp+68   fond
  366. ; sp+72   forme
  367. ; sp+76   lettres
  368. ; sp+80   base
  369.  
  370.        cseg
  371.            public _afi040
  372. _afi040:
  373.         movem.l d0-d7/a0-a4,-(sp)
  374.         clr.l   d0
  375.         clr.l   d1
  376.         clr.l   d2
  377.         clr.l   d3
  378.         clr.l   d4
  379.         clr.l   d5
  380.         clr.l   d6
  381.         clr.l   d7
  382.  
  383.         move.l  76(sp),a1      ; a1 --> lettres
  384.         move.l  56(sp),d0      ; d0 = ascii  w
  385.         lsl.l   #3,d0          ; 
  386.         adda.l  d0,a1          ; a1 = lettre+8*ascii
  387.       
  388.         move.l  64(sp),d0      ; d0 = y   
  389.         muls    #40,d0         ; d0 = 40*y
  390.         add.l   60(sp),d0      ; d0 = 40*y+x 
  391.  
  392.         move.l  68(sp),d1      ; d1 = fond  
  393.         move.l  72(sp),d2      ; d2 = forme 
  394.  
  395.         move.l  #15,d7
  396.         sub.l   d1,d7
  397.         move.l  d7,d1
  398.  
  399.         move.l  #15,d7
  400.         sub.l   d2,d7
  401.         move.l  d7,d2        
  402.  
  403.         move.w  #7,d3          ; 8 lignes
  404.  
  405. bouc1   move.l  80(sp),a0      ; base   PLANEPTR
  406.         adda.l  #12,a0         ; a0 --> ptr  plan3
  407.         move.l  (a0),a2        ; a2 --> plan3
  408.  
  409.         move.w  #3,d4          ; 4 plans
  410.  
  411. bouc2   move.b  0(a1,d3.w),d5    ; d5=ligne de matrice caractere
  412.         clr.l   d6         ; d6 = 0     
  413.         btst    d4,d2            ; test plan de couleur caract
  414.         bne     label0           ; pas de couleur caract ds ce plan
  415.         move.b  d5,d6            ; d6=ligne de matrice caractere
  416.  
  417. label0  btst    d4,d1            ; test plan de couleur fond 
  418.         beq     label1           ; oui
  419.         clr.l   d5               ; non, effacement matrice caractere
  420.         bra     label2           ; vers affichage
  421.  
  422. label1  not.b   d5               ; matrice inverse
  423.  
  424. label2  or.b    d6,d5            ; 
  425.         move.b  d5,0(a2,d0.w)
  426.         suba.l  #4,a0
  427.         move.l  (a0),a2
  428.         dbra     d4,bouc2
  429.  
  430.         add.l   #40,d0
  431.         dbra    d3,bouc1
  432.  
  433.         movem.l (sp)+,d0-d7/a0-a4
  434.         rts
  435.  
  436. #endasm
  437. /********************************************/
  438.  
  439. void delay(compte)
  440. int compte;
  441. {
  442.     Delay((long)compte/100);
  443. }
  444.  
  445. void bell()
  446. {sons(NameNoise,(UWORD)301,longueur);Delay(50); silence();}
  447.  
  448. void joumus(a )
  449. int a;
  450. {
  451. UWORD   musica[64];
  452. int i;
  453.  musica[0]  =253; musica[1]  =284; musica[2]  =301; musica[3]  =284;
  454.  musica[4]  =239; musica[5]  =0;   musica[6]  =0;   musica[7]  =0;
  455.  musica[8]  =213; musica[9]  =239; musica[10] =253; musica[11] =239;
  456.  musica[12] =190; musica[13] =0;   musica[14] =0;   musica[15] =0;
  457.  musica[16] =179; musica[17] =189; musica[18] =201; musica[19] =189;
  458.  musica[20] =127; musica[21] =142; musica[22] =151; musica[23] =142;
  459.  musica[24] =127; musica[25] =142; musica[26] =151; musica[27] =142;
  460.  musica[28] =119; musica[29] =0;   musica[30] =0;   musica[31] =0;
  461.  musica[32] =142; musica[33] =0;   musica[34] =119; musica[35] =0;
  462.  musica[36] =127; musica[37] =0;   musica[38] =142; musica[39] =0;
  463.  musica[40] =159; musica[41] =0;   musica[42] =142; musica[43] =0;
  464.  musica[44] =127; musica[45] =0;   musica[46] =142; musica[47] =0;
  465.  musica[48] =159; musica[49] =0;   musica[50] =142; musica[51] =0;
  466.  musica[52] =127; musica[53] =0;   musica[54] =142; musica[55] =0;
  467.  musica[56] =159; musica[57] =0;   musica[58] =169; musica[59] =0;
  468.  musica[60] =190; musica[61] =0;   musica[62] =0;   musica[63] =0;
  469.  
  470.  if (musicok)
  471.   {
  472.    for (i =a*8;i<=(a+1)*8-1;i++)
  473.      if (musica[i]==0 ) delay(100);
  474.      else   { sons(NameNoise,musica[i],longueur);
  475.               Delay(1);
  476.               silence();
  477.              }
  478.    }
  479.  
  480. }
  481.  
  482. void musbon() 
  483. {
  484. joumus( random(4) );
  485. }
  486.  
  487. void musmoyen()
  488. {
  489.   if(musicok) { sons(NameNoise,(UWORD)479,longueur);Delay(50); silence();}
  490. }
  491. void musmauvais()
  492. {
  493. if (musicok) { sons(NameNoise,(UWORD)954,longueur);Delay(50); silence();}
  494. }
  495. void musfin()
  496. {
  497. int i;
  498.  for (i =1;i<=7;i++) joumus(i);
  499. }
  500.  
  501. void musiqu(number )
  502. int number;
  503. {
  504.  switch( number ) {
  505.    case 0 : musbon();break;
  506.    case 1 : musmauvais();break;
  507.    case 2 : musmoyen();break;
  508.  }
  509. }
  510. int random(echelle)
  511. int echelle;
  512. {
  513.   return(rand()%echelle);
  514. }
  515.  
  516.  
  517. void lecture()
  518. {
  519. BOOL relache;
  520.     int caract,qualif;
  521.     ModifyIDCMP(window,RAWKEY);
  522.      evenmt = 0;
  523. do
  524.     relache=FALSE;
  525.     while((intuiMessage=(struct IntuiMessage *)GetMsg(window->UserPort))!=NULL)
  526.        ReplyMsg(intuiMessage);
  527.  
  528.   while((intuiMessage=(struct IntuiMessage *)GetMsg(window->UserPort))==NULL);
  529.  
  530.    switch(intuiMessage->Class)
  531.     {
  532.      /* case MOUSEBUTTONS : 
  533.             if((intuiMessage->Code)==SELECTDOWN)
  534.              { evenmt=eCLIC; clicx=(int)intuiMessage->MouseX;
  535.                              clicy=(int)intuiMessage->MouseY;
  536.              }
  537.              break;*/
  538.       case RAWKEY :
  539.           evenmt=eCLAV;
  540.           qualif=(int)intuiMessage->Qualifier;
  541.           caract=(int)intuiMessage->Code; 
  542.           switch (caract)
  543.             {
  544.                 case 0x0E :
  545.                 case 0x1C :
  546.                 case 0x2B :
  547.                 case 0x2C :
  548.                 case 0x3B : evenmt=0; break;
  549.                 case 0x40 : ch=spc; break;
  550.                 case 0x41 : ch=del; break;
  551.                 case 0x43 :
  552.                 case 0x44 : ch=13; break;  /* RETURN et ENTER */
  553.                 case 0x45 : ch=esc; break;
  554.                 case 0x46 : ch=clr; break;
  555.                 case 0x4C : ch=fh;  break;
  556.                 case 0x4D : ch=fb;  break;
  557.                 case 0x4E : ch=fd;  break;
  558.                 case 0x4F : ch=fg;  break;
  559.                 default   : if(caract<=0x003F) 
  560.                               { if( (qualif&0x0004) >> 2 ^ (qualif&0x0003)>0 )        
  561.                                  ch=pointeurkm[caract*2];
  562.                                  else
  563.                                  ch=pointeurkm[caract*2+1];
  564.                                 if(qualif&0x0008) ch=upcase(ch)-64;
  565.                              /*  if((ch>='a') && (ch<='z')) ch=ch-32;*/                            
  566.                                } 
  567.                             else 
  568.                               if(caract>=0x0080) relache=TRUE;
  569.                               else{ evenmt=0; ch=255;}
  570.                             break;
  571.             }
  572.           break;
  573.  
  574.      }
  575.     ReplyMsg(intuiMessage);
  576.  
  577.   while((intuiMessage=(struct IntuiMessage *)GetMsg(window->UserPort))!=NULL)
  578.    ReplyMsg(intuiMessage);
  579. }
  580. while(relache);
  581.    ModifyIDCMP(window,0L);
  582. }
  583. void fencoul(x,y,l,h,couleur)
  584. int x,y,l,h,couleur;
  585. {
  586.  SetDrMd(rastPort,JAM1);
  587.  SetAPen(rastPort,(long)couleur) ;
  588.  SetOPen(rastPort,(long)couleur) ;
  589.  RectFill( rastPort,(long)(x*8),(long)y,(long)((x+l)*8-1),(long)(y+h-1) ) ;
  590. }
  591. char *nomFichier(nom,suf)
  592. char *nom,*suf;
  593. {
  594.  
  595.     strcpy( filename,"df0:");
  596.     strcat(filename,nom);
  597.     strcat(filename,suf);
  598.     return(filename);
  599. }
  600. void trait(x1,y1,x2,y2,c)
  601. int x1,y1,x2,y2,c;
  602. {
  603.     SetAPen(rastPort,(long)c);
  604.     Move(rastPort,(long)x1,(long)y1);
  605.     Draw(rastPort,(long)x2,(long)y2);
  606. }
  607.  
  608. void ouvrefen(X,Y,L,H)
  609. int X,Y,L,H;
  610. {
  611.     int i;
  612.     X*=8; L*=8;
  613.     if(numfen<10)
  614.     {
  615.         fen[numfen].x=X; fen[numfen].y=Y; fen[numfen].l=L; fen[numfen].h=H;
  616.         fen[numfen].bit=AllocMem((long)sizeof(struct BitMap),MEMF_CLEAR);
  617.         InitBitMap(fen[numfen].bit,4L,(long)L,(long)H); 
  618.         if(fen[numfen].bit==NULL) fencoul(10,20,2,10,15);
  619.         for(i=0;i<4;i++) 
  620. if( (fen[numfen].bit->Planes[i]=(PLANEPTR)AllocRaster((long)L,(long)H) )==NULL)
  621.       fencoul(10,20,2,10,15);
  622.      if(( BltBitMap(bitMap,(long)X,(long)Y,fen[numfen].bit,0L,0L,(long)L,
  623.                     (long)H,  0x00C0,0x00FF,NULL ))!=4L) fencoul(0,0,1,50,15);
  624.         numfen++;
  625.     }
  626. }
  627.  
  628. void fermefen()
  629. {
  630.     int i;
  631.     LONG X,Y,L,H;
  632.     if(numfen>0)
  633.     {
  634.         numfen--;
  635.         X=(long)fen[numfen].x; Y=(long)fen[numfen].y;
  636.         L=(long)fen[numfen].l;H=(long)fen[numfen].h;
  637.         BltBitMap(fen[numfen].bit,0L,0L,bitMap,X,Y,L,H,0x00C0,0x00FF,NULL);
  638.         for(i=0;i<4;i++) FreeRaster(fen[numfen].bit->Planes[i],L,H);
  639.         FreeMem(fen[numfen].bit,(long)sizeof(struct BitMap));
  640.     }
  641. }
  642.  
  643.  
  644. CHAINE fconcat(a,b,c)
  645. char *a,*c; 
  646. CHAINE *b;
  647. {
  648. CHAINE x;
  649. int i,j;
  650. i=0;
  651. for (;*a;a++) {i++; x.c[i]=*a; }
  652. for(j=1;j<=b->len;j++) {i++; x.c[i]=b->c[j];}
  653. for (;*c;c++) {i++; x.c[i]=*c; }
  654. x.len=i; x.c[i+1]=0;
  655. return(x);
  656. }
  657. #define concat(a,b,c) fconcat(a,&(b),c)
  658.  
  659. CHAINE cconcat(a,c)
  660. CHAINE a;
  661. char c;
  662. {
  663. a.len+=1;
  664. a.c[a.len]=c;
  665. a.c[a.len+1]=0;
  666. return(a);
  667. }
  668.  
  669. CHAINE fcopy(c,d,f)
  670. CHAINE *c;
  671. int d,f;
  672. {
  673. CHAINE x;
  674. int i;
  675. for(i=1;i<=f;i++) {x.c[i]=c->c[i+d-1];}
  676. x.len=f; x.c[f+1]=0;
  677. return(x);
  678. }
  679. #define copy(a,b,c) fcopy(&(a),b,c)
  680.  
  681. int fpos(s,c)
  682. char *s;
  683. CHAINE *c;
  684. {
  685.  char *s1;
  686.  int i,j,t;
  687.  t=c->len-strlen(s)+1;
  688.  for(i=1;i<=t;i++)
  689.  { 
  690.   for(j=i,s1=s;*s1 && j<=c->len && c->c[j]==*s1 ;s1++,j++) ;
  691.  if(!*s1) return(i);
  692.  }
  693.  return(0);
  694. }
  695. #define pos(a,b) fpos(a,&(b))
  696.  
  697. void fdelete(c,d,f)
  698. CHAINE *c;
  699. int d,f;
  700. {
  701. int i;
  702. for(i=d+f;i<=c->len;i++) c->c[i-f]=c->c[i];
  703. c->len-=f;
  704. c->c[c->len+1]=0;
  705. }
  706. void finsert(s,c,p)
  707. char *s;
  708. CHAINE *c;
  709. int p;
  710. {
  711. int i,j;
  712. j=strlen(s);
  713. for(i=c->len;i>=p;i--) c->c[i+j]=c->c[i];
  714. for(i=p;*s;s++,i++) c->c[i]=*s;
  715. c->len+=j;
  716. c->c[c->len+1]=0;
  717. }
  718. void fcinsert(cc,c,p)
  719. char cc;
  720. CHAINE *c;
  721. int p;
  722. {
  723. for(i=c->len;i>=p;i--) c->c[i+1]=c->c[i];
  724. c->c[p]=cc;
  725. c->len+=1;
  726. c->c[c->len+1]=0;
  727. }
  728. #define delete(a,b,c) fdelete(&(a),b,c)
  729. #define insert(a,b,c) finsert(a,&(b),c)
  730. #define cinsert(a,b,c) fcinsert(a,&(b),c)
  731.  
  732. CHAINE atoch(s)
  733. char *s;
  734. {
  735. CHAINE x;
  736. int i;
  737. i=0;
  738. for(;*s;s++) {i++; x.c[i]=*s;}
  739. x.len=i;
  740. x.c[i+1]=0;
  741. return(x);
  742. }
  743.  
  744. CHAINE ctoch(c)
  745. char c;
  746. {
  747. CHAINE x;
  748. x.c[1]=c;
  749. x.c[2]=0;
  750. x.len=1;
  751. return(x);
  752. }
  753.  
  754.  
  755. BOOL idem(a,b)
  756. CHAINE a,b;
  757. {
  758. int i;
  759. for(i=1;i<=a.len;i++) if (i>b.len||a.c[i]!=b.c[i]) return(FALSE);
  760. if (a.len==b.len) return(TRUE); else return(FALSE);
  761. }
  762. #define length(x) (x.len)
  763.  
  764.  
  765. char   upcase(maj)
  766. char maj;
  767.  {
  768.   if ((maj>96) && (maj<123)) return(maj-32);
  769.   else return(maj);
  770.  }
  771.  
  772. void effecr()
  773. { fencoul(0,0,40,200,4);}
  774.  
  775. void pass80()
  776. { typecr =80;effecr();}
  777.  
  778. void pass40()
  779. { typecr =40;effecr();}
  780.  
  781.  
  782. void efffen( abscisse,ordonnee,larg,haut)
  783. int abscisse, ordonnee, larg, haut;
  784. {
  785.  if (typecr==80)  fencoul(abscisse / 8,ordonnee,larg / 8,haut,4);
  786.  else fencoul(abscisse / 8,ordonnee,larg / 8,haut,4);
  787. }
  788.  
  789.  
  790. void prelig(max)
  791. int max; 
  792. {
  793. int lon;
  794. BOOL sort;
  795.  buflig=atoch("");lon =0;sort =FALSE;
  796.  do 
  797. {
  798.   buflig =cconcat(buflig,(char)litab(pointe));
  799.   lon =lon+1;
  800.   switch( litab(pointe) ) {
  801.    case 123:
  802.    case 125:
  803.    case 91 :
  804.    case 93 : lon =lon-1;break;
  805.    case 0:
  806.    case 64 :  delete (buflig,length(buflig),1);sort =TRUE; break;
  807.   }
  808.   pointe =pointe+1;
  809.  } while(!( (lon==max) || (sort)));
  810.  if (! sort )
  811.  {
  812.   int c;
  813.    c=litab(pointe);
  814.    while ( c==123||c==125||c==91||c==93)
  815.     {
  816.      buflig =cconcat(buflig,(char)c);pointe =pointe+1; c=litab(pointe);
  817.     }
  818.    switch( litab(pointe) ) {
  819.     case 32:
  820.     case 64:
  821.     case 0 :  pointe =pointe+1;sort =TRUE;break;
  822.    }
  823.    if (pos(" ",buflig)==0 ) sort =TRUE;
  824.    if (! sort )
  825.     {
  826.      lon =length(buflig);
  827.      while ( buflig.c[lon]!=' '){ lon =lon-1;pointe =pointe-1;}
  828.      delete(buflig,lon,length(buflig)-lon+1);
  829.      
  830.     }
  831.  }
  832. }
  833. void aficar(ascii)
  834. char ascii;
  835. {
  836.      int x1,x2,y1,y2,i,h;
  837.      x1=posx*8; x2=x1+7;  h=hauteur/2-4;
  838.      for(i=0;i<h;i++) 
  839.          {trait(x1,posy+7+i+1,x2,posy+7+i+1,c_fond);
  840.          trait(x1,posy-i-1,x2,posy-i-1,c_fond);}
  841.  
  842.      afi040((int)ascii,posx,posy,c_fond,c_forme,lettres,&(bitMap->Planes[0]));
  843.      if(souli) 
  844.      {
  845.            y1=posy+7+(hauteur-8)/2;
  846.           trait(x1,y1,x2,y1,c_forme);
  847.      }
  848.      if(cadre)
  849.      {
  850.           x1--; x2+=2; y1=posy+(hauteur-8)/2-1; y2=y1+9;
  851.           trait(x1,y1,x2,y1,c_forme); trait(x2,y1,x2,y2,c_forme);
  852.           trait(x2,y2,x1,y2,c_forme); trait(x1,y2,x1,y1,c_forme);
  853.      }
  854. posx+=1; if(posx==typecr) { posx=0; posy+=hauteur;}
  855.  
  856. }
  857. void afilig(tampon,x,y,c1,c2)
  858. int x,y,c1,c2;
  859. char *tampon;
  860. {
  861.      char car;
  862.      int i;
  863.  
  864.      c_forme=c1;
  865.      if(c_deux == TRUE) c_forme=c2;
  866.      posx=x; posy=y;
  867.      for(i=0;i<strlen(tampon);i++)
  868.      {
  869.           switch (tampon[i])
  870.           {
  871.                case '[': c_forme=c2; c_deux=TRUE; break;
  872.                case ']': c_forme=c1; c_deux=FALSE; break;
  873.                case '{': souli=TRUE; break;
  874.                case '}': souli=FALSE; break;
  875.                default : aficar(tampon[i]);  
  876.           }
  877.      }
  878. }
  879.  
  880.  
  881. void curinv(xx,yy)
  882. int xx,yy;
  883.  { 
  884.   buflig =ctoch(bufsais.c[curse+1]);c_deux =TRUE;c_fond =7;
  885.  afilig(&(buflig.c[1]),xx,yy,0,0);
  886.   c_deux =FALSE;c_fond =4;
  887.  }
  888.  
  889. void fincurinv(xx,yy )
  890. int xx,yy;
  891.  { buflig =ctoch(bufsais.c[curse+1]);afilig(&(buflig.c[1]),xx,yy,blanc,blanc);}
  892.  
  893.  
  894. void saisie (posx,posy,lon,debut)
  895. int posx,posy,lon;
  896. BOOL debut;
  897. {
  898. int  lonpre,lgr ;
  899. BOOL  deuze ;
  900. CHAINE aprelig ;
  901. char l;
  902.  souli =FALSE;cadre =FALSE;deuze =TRUE;aprelig =atoch("");sortie =FALSE;
  903.  if (debut ) curse =0;
  904.  lgr =length(bufsais);
  905.  while ( length(bufsais)<80) bufsais =cconcat(bufsais,' ');
  906.   do {
  907.   if (lon+posx<typecr )
  908.    {
  909.     buflig =copy(bufsais,1,lon);
  910.     lonpre =lon;deuze =FALSE;
  911.     afilig(&(buflig.c[1]),posx,posy,blanc,blanc);
  912.    }
  913.   else
  914.    {
  915.     if ((lgr+posx<typecr) && (! deuze) )
  916.      {
  917.       buflig =copy(bufsais,1,typecr-posx);deuze =FALSE;
  918.       lonpre =lgr;afilig(&(buflig.c[1]),posx,posy,blanc,blanc);
  919.      }
  920.     else
  921.      {
  922.       buflig =copy(bufsais,1,typecr-posx);
  923.       while(buflig.c[length(buflig)]!=' '&&typecr+1-posx-length(buflig)<12)
  924.                delete(buflig,length(buflig),1);
  925.        if (buflig.c[length(buflig)]!=' ' ) buflig =copy(bufsais,1,typecr-posx);
  926.        lonpre =length(buflig);
  927.        if (lonpre>lgr )
  928.         {
  929.          lonpre =lgr;
  930.          if (deuze ) fencoul(0,posy+10,typecr,hauteur,c_fond);
  931.          deuze =FALSE;
  932.         }
  933.        else deuze =TRUE;
  934.       while ( length(buflig)<typecr-posx) buflig =cconcat(buflig,' ');
  935.        if (!idem(buflig,aprelig) )
  936.         { aprelig =buflig;afilig(&(buflig.c[1]),posx,posy,blanc,blanc);}
  937.          if (deuze )
  938.           {
  939.            buflig =copy(bufsais,lonpre+1,typecr);
  940.            afilig(&(buflig.c[1]),0,posy+10,blanc,blanc);
  941.           }
  942.      }
  943.    }
  944.   do {
  945.    if ( (lonpre==lgr || curse<lonpre) && curse<typecr-posx )
  946.     curinv(posx+curse,posy);
  947.    else curinv(curse-lonpre,posy+10);
  948.    do lecture(); while(evenmt!=eCLAV);
  949.    if (((lonpre==lgr) || (curse<lonpre)) && (curse<typecr-posx) )
  950.     fincurinv(posx+curse,posy);
  951.    else fincurinv(curse-lonpre,posy+10);
  952.    switch( ch ) {
  953.    case  fh : if (curse<=lonpre || (curse-lonpre)<posx ) bell();
  954.          else curse =curse-lonpre-posx;break;
  955.     case fb : if ((curse>lonpre) || (curse+lonpre+posx>lgr) ) bell();
  956.          else curse =curse+lonpre+posx;break;
  957.     case fd :  curse =curse+1;if (curse>lgr )
  958.                                { curse =curse-1;bell();} break;
  959.     case fg :  curse =curse-1;if (curse==-1)
  960.                      { curse =0;bell();} break;
  961.    }
  962.   } while(  ch==fh||ch==fb||ch==fd||ch==fg);
  963.   switch( ch ) 
  964.   {
  965.    case del : if (curse>0 )
  966.          {
  967.           delete(bufsais,curse,1);bufsais =cconcat(bufsais,' ');
  968.           lgr =lgr-1;curse =curse-1;   
  969.          }
  970.         else bell(); break;
  971.    case clr: if (lgr>curse )
  972.          { delete(bufsais,curse+1,1);
  973.           bufsais =cconcat(bufsais,' ');
  974.           lgr =lgr-1;}
  975.          else bell();break;
  976.    case esc: sortie =TRUE;break;
  977.    default : if (((ch>31) && (ch<91)) || ((ch>96) && (ch<123)) )
  978.          {
  979.           if (lgr<lon )
  980.            {
  981.             bufsais =copy(bufsais,1,79);
  982.             curse =curse+1;cinsert(ch,bufsais,curse);
  983.             lgr =lgr+1;
  984.            }
  985.           else bell();break;
  986.          }
  987.    }
  988.  } while(!( (ch==13) || (ch==0) || (sortie==TRUE) ));
  989.   filtre(); 
  990. }
  991.  
  992.  
  993. void affiche(x,y,l,h,adresse)
  994. int x,y,l,h;
  995. LONG adresse;
  996. {
  997. afiimbr(x,y,l,h,adresse,&(bitMap->Planes[0]) );
  998. }
  999.  
  1000. void afiimage(pointer)
  1001. LONG pointer;
  1002. {
  1003.  int large,haute,posix,posiy,taille,i;
  1004.  int numero,numfich;
  1005.  taille =litab(pointer+1)*256+litab(pointer+2);
  1006.  large =litab(pointer+5);haute =litab(pointer+6);
  1007.  posix =litab(pointer+3);posiy =litab(pointer+4);
  1008.  if ((litab(pointer) & 63)==1 )
  1009.   {
  1010.    pointer =pointer+7;
  1011.    affiche(posix,posiy,large,haute,tableau+pointer);
  1012.   }
  1013.  adr_retour =0;
  1014. }
  1015.  
  1016. int egal()
  1017. {
  1018. int  i,diffec ;
  1019.  sortie =FALSE;
  1020.  if (idem(buflig,bufsais) ) { return(0);}
  1021. i=length(buflig)-length(bufsais);
  1022.  if (i<-1 || i>1 ) return(2);
  1023.  diffec =0;
  1024.  if (length(buflig)==length(bufsais) )
  1025.   {
  1026.    for (i =1;i<=length(buflig);i++)
  1027.     if (buflig.c[i]!=bufsais.c[i] ) diffec =diffec+1;
  1028.   }
  1029.  else
  1030.   if (length(buflig)<length(bufsais) )
  1031.    for (i =1;i<=length(buflig);i++)
  1032.     if (buflig.c[i]!=bufsais.c[i] )
  1033.      {
  1034.       if (buflig.c[i]!=bufsais.c[i+1] )  return(2);
  1035.        diffec =diffec+1;
  1036.        if (diffec==1 ) delete(bufsais,i,1);
  1037.      }
  1038.   else
  1039.    for (i =1;i<=length(bufsais);i++)
  1040.     if (buflig.c[i]!=bufsais.c[i] )
  1041.      {
  1042.       if (bufsais.c[i]!=buflig.c[i+1] ) return(2);
  1043.       diffec =diffec+1;
  1044.       if (diffec==1 ) delete(buflig,i,1);
  1045.      }
  1046.    if (diffec==0 ) diffec =1;
  1047.     if (diffec>2 ) diffec =2;
  1048.     return(diffec);
  1049. }
  1050.  
  1051. void commen(number,endy )
  1052. int number,endy;
  1053. {
  1054.  int nombre ;
  1055.  int i;
  1056.  pointe =litab(4L)*256+litab(5L);
  1057.  if (pointe!=0 )
  1058.   {
  1059.    nombre =litab(pointe);pointe =pointe+1;
  1060.    for (i =1;i<=number*nombre+random(nombre);i++)
  1061.                    pointe =pointe+litab(pointe)+1;
  1062.    pointe =pointe+1;prelig(typecr);
  1063.              afilig(&(buflig.c[1]),(typecr-length(buflig))/ 2,endy,jaune,jaune);
  1064.   }
  1065.  musiqu(number);
  1066. }
  1067.  
  1068.  
  1069. void initSons()
  1070. {
  1071.   FILE *fp;
  1072.   ULONG Length;
  1073.   UWORD Smprate;
  1074.  
  1075.   fp=fopen("df0:note.smp","r");
  1076.  
  1077.   fread(&Length,sizeof(Length),1,fp);
  1078.   fread(&Smprate,sizeof(Smprate),1,fp);
  1079.   NameNoise=(BYTE *)AllocMem((long)Length,MEMF_CHIP|MEMF_CLEAR);
  1080.   fread(NameNoise,Length,1,fp);
  1081.   fclose(fp);
  1082.   longueur=(UWORD)(Length/2);
  1083.  
  1084. }
  1085.  
  1086.  
  1087.  
  1088. void initCouleurs()
  1089. {
  1090. SetRGB4(&screen->ViewPort,  0L, 0L, 0L, 0L);
  1091. SetRGB4(&screen->ViewPort,  1L, 14L, 0L,  0L);
  1092. SetRGB4(&screen->ViewPort,  2L, 0L, 14L,  0L);
  1093. SetRGB4(&screen->ViewPort,  3L, 14L, 14L,  0L);
  1094. SetRGB4(&screen->ViewPort,  4L, 0L, 0L,  14L);
  1095. SetRGB4(&screen->ViewPort,  5L, 14L, 0L,  14L);
  1096. SetRGB4(&screen->ViewPort,  6L, 0L, 14L,  14L);
  1097. SetRGB4(&screen->ViewPort,  7L, 14L, 14L,  14L);
  1098. SetRGB4(&screen->ViewPort,  8L, 10L, 10L, 10L);
  1099. SetRGB4(&screen->ViewPort,  9L, 10L, 6L,  6L);
  1100. SetRGB4(&screen->ViewPort,  10L, 4L, 10L,  6L);
  1101. SetRGB4(&screen->ViewPort,  11L, 12L, 12L, 4L);
  1102. SetRGB4(&screen->ViewPort,  12L, 8L, 6L,  14L);
  1103. SetRGB4(&screen->ViewPort,  13L, 14L, 10L,  12L);
  1104. SetRGB4(&screen->ViewPort,  14L, 10L, 14L,  14L);
  1105. SetRGB4(&screen->ViewPort,  15L, 12L, 10L,  0L);
  1106. }
  1107.  
  1108.  
  1109. void initPolice()
  1110. {
  1111.   FILE *fp;                                               
  1112.   fp = fopen("df0:lettres.bin","r"); 
  1113.   lettres=(UBYTE *)AllocMem(sizeof(BYTE)*1024L,MEMF_PUBLIC|MEMF_CLEAR);
  1114.   fread(lettres,1024L,1,fp);
  1115.   fclose(fp);                               
  1116. }
  1117.  
  1118.  
  1119. void initMem()
  1120. {
  1121.     tableau=(UBYTE *)AllocMem(MEMOIRE,MEMF_CHIP|MEMF_CLEAR);
  1122. }
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128. LONG filesize(nom)
  1129. char *nom ;
  1130. {
  1131.  struct FileLock *lock ;
  1132.  LONG taille;
  1133.  struct FileInfoBlock *fileInfoBlock;
  1134.  
  1135.   fileInfoBlock = AllocMem((long)sizeof(struct FileInfoBlock),MEMF_CLEAR) ;
  1136.   lock = Lock(nom,ACCESS_READ) ; if( lock == NULL ) return(-1) ;
  1137.   if( Examine(lock,fileInfoBlock) == FALSE ) return(-1) ;
  1138.   UnLock((long)lock) ; 
  1139.   taille=fileInfoBlock->fib_Size ;
  1140.   FreeMem(fileInfoBlock,(long)sizeof(struct FileInfoBlock));
  1141.   return(taille);
  1142. }
  1143.  
  1144.  
  1145.  
  1146. BOOL initMachine()
  1147. {
  1148.     if( (GfxBase=(struct GfxBase *)OpenLibrary((UBYTE *)"graphics.library",0L))
  1149.          == NULL )  return(FALSE);
  1150.     if( (IntuitionBase=(struct IntuitionBase *)
  1151.             OpenLibrary((UBYTE *)"intuition.library",0L))==NULL) return(FALSE);  
  1152.     amigadoswin = IntuitionBase->ActiveWindow;
  1153.     sourisOff=AllocMem(6*sizeof(UWORD),MEMF_CHIP|MEMF_CLEAR);
  1154.     if((screen=(struct Screen *)OpenScreen(&newScreen))==NULL) return(FALSE);
  1155.     newWindow.Screen=screen;
  1156.     if((window=(struct Window *)OpenWindow(&newWindow))==NULL) return(FALSE);
  1157.     ShowTitle(screen,FALSE);
  1158.     rastPort=&screen->RastPort;
  1159.     bitMap=rastPort->BitMap;
  1160.     viewPort=&screen->ViewPort; 
  1161.     srand((int)time(0L));
  1162.     CloseWindow(amigadoswin);
  1163.     CloseWorkBench();
  1164.     hide_mouse();
  1165.     ActivateWindow(window);
  1166.     return(TRUE);
  1167. }
  1168.  
  1169. exitMachine()
  1170. {
  1171.     if(window != NULL) CloseWindow(window);
  1172.     if(screen != NULL) CloseScreen(screen);
  1173.     OpenWorkBench(); 
  1174.     if( IntuitionBase != NULL) CloseLibrary(IntuitionBase);
  1175.     if( GfxBase != NULL) CloseLibrary(GfxBase);
  1176.     exit();
  1177. }
  1178.  
  1179.  
  1180. void readfichier(nom,ptr)
  1181. char *nom;
  1182. UBYTE *ptr ;
  1183. {
  1184.      struct FileHandle *file ;
  1185.      LONG taille ;
  1186.      taille = filesize(nom) ;
  1187.      file = Open(nom,MODE_OLDFILE); 
  1188.      Read(file,ptr,taille) ;
  1189.      Close(file) ;
  1190. }
  1191.  
  1192.  
  1193. void crefen(x,y,l,h)
  1194. int x,y,l,h ;
  1195. {
  1196.      ouvrefen(x,y,l,h);
  1197. }
  1198.  
  1199. void restore()
  1200. {
  1201.     fermefen();
  1202. }
  1203.  
  1204. void efface(couleur)
  1205. int couleur;
  1206. {
  1207.      if(typecr == 40) fencoul(0,0,40,200,couleur);
  1208. }
  1209.  
  1210. void attente()
  1211. {
  1212. char car;
  1213.  hauteur=8;
  1214.  afilig("\010\011",typecr-2,192,rose,rose);
  1215. car=ch;
  1216.  do lecture(); while(evenmt==0);
  1217. ch=car;
  1218. }
  1219.  
  1220. BOOL keypress()
  1221. {
  1222. return(TRUE);
  1223. }
  1224.  
  1225. LONG cconin()
  1226. {
  1227. lecture();
  1228. return((long)ch);
  1229. }
  1230. void exitJeu()
  1231. {
  1232. FreeMem(tableau,MEMOIRE);
  1233. }
  1234.  
  1235. void initCharge()
  1236. {
  1237.  char car,cs[2];
  1238.  c_fond=4;  
  1239.  car =choix();
  1240.  cs[1]=(char)0;
  1241. if (! sortie) 
  1242.   {
  1243.    cs[0]=car;
  1244.    afilig(cs,35,160,blanc,blanc);
  1245.    afilig("Voulez-vous des effets sonores (O/N) ?",1,184,rouge,rouge);
  1246.    do { lecture();ch =upcase(ch);} while( ch!='O' && ch!='N');
  1247.    musicok =(ch=='O');
  1248.    afilig("            Chargement en cours...    ",1,184,blanc,blanc);
  1249.    strcpy(nomfich ,"episode "); nomfich[7]=car;
  1250.    readfichier(nomFichier(nomfich,".tot"),tableau);
  1251.   }
  1252. }
  1253.  
  1254.  
  1255. void initJeu()
  1256. {
  1257.     numfen=0;
  1258.     compteur=0;
  1259.     vide.len=0;
  1260.     vide.c[0]=0;
  1261.     vide.c[1]=0;
  1262.      initMem();
  1263.      initCouleurs();
  1264.      initPolice();
  1265.      initSons();
  1266.     
  1267. }
  1268.  
  1269. main()
  1270. {
  1271.  int i,j;
  1272.  
  1273.      if(initMachine()==TRUE)
  1274.        {
  1275.           initJeu();
  1276.           do 
  1277.           {
  1278.                initCharge();
  1279.                if (!sortie) executeur(); 
  1280.           } 
  1281.           while (!sortie) ;
  1282.           exitJeu() ;
  1283.      }
  1284.      exitMachine();   
  1285.  
  1286. }
  1287.